<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

$VIEW->template = 'admin-thickbox.tpl';


$CONFIG->debug = true;


$blockid = get('id');

$blockids = explode('-', $blockid);

if(count($blockids)==2){
    // is a page block
    JFX::addError('Cannot update styles on the page block');
    return;
}

$block = new JFX_Block;
if(!$block->loadById($blockid, '', false, true)){
    die('This block has not been saved!');
}

$details = $block->getDetails();




if(Antz_IntelliForm::submitted('update-block-style')){
    $block->setClassName(post('class'));
    $block->setTemplate(post('template', '', 5000));
    $block->setStyle(post('style', '', 5000));
    $block->details['is_droppable'] = (int) post('droppable');
    $block->save();
    JFX::addSuccess('Styles Updated!');
}











$formFields = array(
    array(
        'type' => 'text',
        'name' => 'class',
        'value' => post('class', $block->getClassName()),
        'label' => 'Class Names'
    ),
    array(
        'type' => 'checkbox',
        'name' => 'droppable',
        'value' => 1,
        'label' => 'Is droppable',
        'checked' => (post('droppable', $details['is_droppable']))
    ),
    array(
        'type' => 'textarea',
        'name' => 'template',
        'value' => post('template', $block->getTemplate()),
        'label' => 'Template'
    ),
    array(
        'type' => 'textarea',
        'name' => 'style',
        'value' => post('style', $details['block_style']),
        'label' => 'CSS Style'
    ),
    array(
        'type' => 'submit',
        'name' => 'submitBtn',
        'value' => 'Update',
        'label' => '&nbsp;'
    )
);


echo JFX::makeRapidForm($formFields, 'Style Settings', 'update-block-style');






